package com.imooc.distributedemo.resume.thread;

import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
import java.util.concurrent.Phaser;

public class PhaserExample {

    public synchronized void getData(){

    }

    public void getData1(){
        synchronized (this){

        }
    }

    public static void main(String[] args) {
        Phaser phaser = new Phaser(3); // 创建 Phaser，设置参与者数量为 3
        ExecutorService executorService = Executors.newFixedThreadPool(3); // 创建线程池

        // 创建 3 个 CalculationTask 实例，并提交到线程池中执行
        for (int i = 0; i < 3; i++) {
            executorService.execute(new CalculationTask(i, phaser));
        }

        // 关闭线程池
        executorService.shutdown();
    }
}
